package views;

import java.awt.BorderLayout;
import java.awt.GridLayout;
import java.awt.Image;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

import controllers.StartMenuController;

public class StartMenuView extends JFrame{

	private static final long serialVersionUID = -3016534456612323927L;

	//Atributos
	private int windowWidth;
	private int windowHeight;
	private int titleHeight;
	
	private Image titleBg;
	private JPanel centerPanel;
	private JPanel northPanel;
	private JLabel lbGameTitle;
	private JButton btNewGame;
	private String btTextNewGame;
	private JButton btAbout;
	private String btTextAbout;
	
	//Construtor
	public StartMenuView()
	{
		windowWidth = 300;
		windowHeight = 300;
		titleHeight = 100;
		btTextNewGame = "Novo Jogo";
		btTextAbout = "Sobre";
		lbGameTitle = new JLabel("Tower Defense");

		//Layout
		this.setLayout(new BorderLayout());
		centerPanel = new JPanel();
		northPanel = new JPanel();
		this.setVisible(true);
		//North
		titleBg = createImage(windowWidth, titleHeight);
		JLabel lbTitle = new JLabel(new ImageIcon(titleBg));
		northPanel.add(lbTitle);
		northPanel.add(lbGameTitle);
		//Center
		btNewGame = new JButton();
		btNewGame.setText(btTextNewGame);
		btAbout = new JButton();
		btAbout.setText(btTextAbout);
		
		centerPanel.setLayout(new GridLayout(2,1));
		centerPanel.add(btNewGame);
		centerPanel.add(btAbout);
		
		this.add("North", northPanel);
		this.add("Center", centerPanel);
		this.pack();
		this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE);
		
	}
	
	//Getters
	public String getBtTextNewGame(){
		return this.btTextNewGame;
	}
	
	public String getBtTextAbout(){
		return this.btTextAbout;
	}
	
	//Setters
	public void setController(StartMenuController smc){
        this.addWindowListener(smc);
        this.btNewGame.addActionListener(smc);
        this.btAbout.addActionListener(smc);
    }


}
